/* 相关保险  */
function getBaoXxx(url){
	$.dpAjax({
		show:true,
 		url:url,
		data:{busiId:busiId},
		success: function(datas){
		  var data = datas.result;
		  if(data) {
			  //保险年度
			 var years = data.years;
			 if(years && years.length > 0) {
				 var html = '';
 				 for(var i = 0; i <  years.length; i++) {
 					 var year_ = years[i];
 					 html += '<option value="' + year_.insuranceId + '">' + year_.year + '</opton>';
 				 }
 				 $('#baox_year').html(html);
			 }
			 
			 showBaox(data);
		  }
     }
});
}

//获取详情
function getBaoxDetail(url){
	var insurancesId = $('#baox_year').val();
	$.dpAjax({
		show:false,
 		url:url,
			data:{insurancesId:insurancesId},
			success: function(datas){
			  var data = datas.result;
			  if(data) {
				 showBaox(data);
			  }
         }
 	});
}


function showBaox(data){
	 //保险
	 var dhInsurance = data.dhInsurance;
	 if(dhInsurance) {
		$('#baox_year').val(dhInsurance.replaceId);
		$('#baox_typeRenewal').text(dhInsurance.typeRenewalDisplay);
		$('#baox_companyInsurance').text(dhInsurance.companyInsuranceDisplay);
		$('#baox_dateStart').text(formateDate(dhInsurance.dateStart));
		$('#baox_dateEnd').text(formateDate(dhInsurance.dateEnd));
		$('#baox_noInsurance').text(dhInsurance.noInsurance);
		
		 $('#baox_isCacel').text(dhInsurance.isCacelDisplay);
		 $('#baox_isLocal').text(dhInsurance.isLocalDisplay);
		 $('#baox_limitLoss').text(showNumber(dhInsurance.limitLoss));
		 $('#baox_limitSteal').text(showNumber(dhInsurance.limitSteal));
		 $('#baox_limitGlass').text(showNumber(dhInsurance.limitGlass));
		 $('#baox_limitAoad').text(showNumber(dhInsurance.limitAoad));
		 $('#baox_limitThird').text(showNumber(dhInsurance.limitThird));
		 $('#baox_limitIgnition').text(showNumber(dhInsurance.limitIgnition));
		 $('#baox_limitWade').text(showNumber(dhInsurance.limitWade));
		 $('#baox_limitPerson').text(showNumber(dhInsurance.limitPerson));
		 $('#baox_limitSpecial').text(showNumber(dhInsurance.limitSpecial));
		 
		 $('#baox_costLoss').text(showNumber(dhInsurance.costLoss));
		 $('#baox_costSteal').text(showNumber(dhInsurance.costSteal));
		 $('#baox_costGlass').text(showNumber(dhInsurance.costGlass));
		 $('#baox_costAoad').text(showNumber(dhInsurance.costAoad));
		 $('#baox_costThird').text(showNumber(dhInsurance.costThird));
		 $('#baox_costIgnition').text(showNumber(dhInsurance.costIgnition));
		 $('#baox_costWade').text(showNumber(dhInsurance.costWade));
		 $('#baox_costPerson').text(showNumber(dhInsurance.costPerson));
		 $('#baox_costSpecial').text(showNumber(dhInsurance.costSpecial));
		 countCostTotal();
		 
		 $('#baox_operatorNext').text(dhInsurance.operatorNextDisplay);
		 $('#baox_dateEffect').text(formateDate(dhInsurance.dateEffect));
		 $('#baox_confirmor').text(dhInsurance.confirmor);
		 $('#baox_timeConfirm').text(formateDate(dhInsurance.timeConfirm));
		 
		 $('#baox_amountRebate').text(showNumber(dhInsurance.amountRebate));
		 $('#baox_amountReceived').text(showNumber(dhInsurance.amountReceived));
		 $('#baox_amountRebateTotal').text(showNumber(dhInsurance.amountRebateTotal));
		 $('#baox_amountReceivedTotal').text(showNumber(dhInsurance.amountReceivedTotal));
		 $('#baox_remarks').html(dhInsurance.remarks);
		 
		 $('#baox_auditor').text(dhInsurance.auditor);
		 $('#baox_timeAudit').text(formateDate(dhInsurance.timeAudit));
	 } else {
		 clearInsurance();
	 }
	 
	//强险
	 var dhInsuranceCompulsory = data.dhInsuranceCompulsory;
	 if(dhInsuranceCompulsory) {
		 $('#baox_q_companyInsurance').text(dhInsuranceCompulsory.companyInsuranceDisplay);
		 $('#baox_q_dateStart').text(formateDate(dhInsuranceCompulsory.dateStart));
		 $('#baox_q_dateEnd').text(formateDate(dhInsuranceCompulsory.dateEnd));
		 $('#baox_q_noInsurance').text(dhInsuranceCompulsory.noInsurance);
		 $('#baox_q_isCacel').text(dhInsuranceCompulsory.isCacelDisplay);
		 $('#baox_q_isLocal').text(dhInsuranceCompulsory.isLocalDisplay);
			 
		 $('#baox_q_objectInsure').text(dhInsuranceCompulsory.objectInsureDisplay);
		 $('#baox_q_costPerson').text(showNumber(dhInsuranceCompulsory.costPerson));
		 $('#baox_q_costSpecial').text(showNumber(dhInsuranceCompulsory.costSpecial));
		 countQcostTotal();
		 
		 $('#baox_q_operatorNext').text(dhInsuranceCompulsory.operatorNextDisplay);
		 $('#baox_q_dateEffect').text(formateDate(dhInsuranceCompulsory.dateEffect));
		 $('#baox_q_confirmor').text(dhInsuranceCompulsory.confirmor);
		 $('#baox_q_timeConfirm').text(formateDate(dhInsuranceCompulsory.timeConfirm));
		 
		 $('#baox_q_amountRebate').text(showNumber(dhInsuranceCompulsory.amountRebate));
		 $('#baox_q_amountReceived').text(showNumber(dhInsuranceCompulsory.amountReceived));
	 } else {
		 clearInsuranceCompulsory();
	 }
}


function countCostTotal(){
	var costLoss = $('#baox_costLoss').text();
	var costLossNum = (!costLoss || costLoss == '' || costLoss == '-') ? 0 : parseFloat(costLoss);
	
	var costSteal = $('#baox_costSteal').text();
	var costStealNum = (!costSteal || costSteal == '' || costSteal == '-') ? 0 : parseFloat(costSteal);
	
	var costGlass = $('#baox_costGlass').text();
	var costGlassNum = (!costGlass || costGlass == '' || costGlass == '-') ? 0 : parseFloat(costGlass);
	
	var costAoad = $('#baox_costAoad').text();
	var costAoadNum = (!costAoad || costAoad == '' || costAoad == '-') ? 0 : parseFloat(costAoad);
	
	var costThird = $('#baox_costThird').text();
	var costThirdNum = (!costThird || costThird == '' || costThird == '-') ? 0 : parseFloat(costThird);
	
	var costIgnition = $('#baox_costIgnition').text();
	var costIgnitionNum = (!costIgnition || costIgnition == '' || costIgnition == '-') ? 0 : parseFloat(costIgnition);
	
	var costWade = $('#baox_costWade').text();
	var costWadeNum = (!costWade || costWade == '' || costWade == '-') ? 0 : parseFloat(costWade);
	
	var costPerson = $('#baox_costPerson').text();
	var costPersonNum = (!costPerson || costPerson == '' || costPerson == '-') ? 0 : parseFloat(costPerson);
	
	var costSpecial = $('#baox_costSpecial').text();
	var costSpecialNum = (!costSpecial || costSpecial == '' || costSpecial == '-') ? 0 : parseFloat(costSpecial);
	
	$('#baox_costTotal').text(showNumber(costLossNum + costStealNum + costGlassNum  + costAoadNum + costThirdNum + costIgnitionNum + costWadeNum + costPersonNum + costSpecialNum)); 
}

function countQcostTotal(){
	var q_costPerson = $('#baox_q_costPerson').text();
	var q_costPersonNum = (!q_costPerson || q_costPerson == '' || q_costPerson == '-') ? 0 : parseFloat(q_costPerson);
	
	var q_costSpecial = $('#baox_q_costSpecial').text();
	var q_costSpecialNum = (!q_costSpecial || q_costSpecial == '' || q_costSpecial == '-') ? 0 : parseFloat(q_costSpecial);
	
	$('#baox_q_costTotal').text(showNumber(q_costPersonNum + q_costSpecialNum));
}

function clearInsurance(){
	$('#baox_year').val('-');
	$('#baox_typeRenewal').text('-');
	$('#baox_companyInsurance').text('-');
	$('#baox_dateStart').text('-');
	$('#baox_dateEnd').text('-');
	$('#baox_noInsurance').text('-');
	
	 $('#baox_isCacel').text('-');
	 $('#baox_isLocal').text('-');
	 $('#baox_limitLoss').text('-');
	 $('#baox_limitSteal').text('-');
	 $('#baox_limitGlass').text('-');
	 $('#baox_limitAoad').text('-');
	 $('#baox_limitThird').text('-');
	 $('#baox_limitIgnition').text('-');
	 $('#baox_limitWade').text('-');
	 $('#baox_limitPerson').text('-');
	 $('#baox_limitSpecial').text('-');
	 
	 $('#baox_costLoss').text('-');
	 $('#baox_costSteal').text('-');
	 $('#baox_costGlass').text('-');
	 $('#baox_costAoad').text('-');
	 $('#baox_costThird').text('-');
	 $('#baox_costIgnition').text('-');
	 $('#baox_costWade').text('-');
	 $('#baox_costPerson').text('-');
	 $('#baox_costSpecial').text('-');
	 
	 $('#baox_costTotal').text('-');
	 
	 $('#baox_operatorNext').text('-');
	 $('#baox_dateEffect').text('-');
	 $('#baox_confirmor').text('-');
	 $('#baox_timeConfirm').text('-');
	 
	 $('#baox_amountRebate').text('-');
	 $('#baox_amountReceived').text('-');
	 $('#baox_amountRebateTotal').text('-');
	 $('#baox_amountReceivedTotal').text('-');
	 $('#baox_remarks').html('-');
	 
	 $('#baox_auditor').text('-');
	 $('#baox_timeAudit').text('-');
}
function clearInsuranceCompulsory(){
	 $('#baox_q_companyInsurance').text('-');
	 $('#baox_q_dateStart').text('-');
	 $('#baox_q_dateEnd').text('-');
	 $('#baox_q_noInsurance').text('-');
	 $('#baox_q_isCacel').text('-');
	 $('#baox_q_isLocal').text('-');
		 
	 $('#baox_q_objectInsure').text('-');
	 $('#baox_q_costPerson').text('-');
	 $('#baox_q_costSpecial').text('-');
	 
	 $('#baox_q_operatorNext').text('-');
	 $('#baox_q_dateEffect').text('-');
	 $('#baox_q_confirmor').text('-');
	 $('#baox_q_timeConfirm').text('-');
	 $('#baox_q_costTotal').text('-');
	 
	 $('#baox_q_amountRebate').text('-');
	 $('#baox_q_amountReceived').text('-');
}

